{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# How to specify a color scheme in Reports and Test Suites?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    import evidently\n",
    "except:\n",
    "    !pip install git+https://github.com/evidentlyai/evidently.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "\n",
    "from evidently.report import Report\n",
    "from evidently.metric_preset.data_drift import DataDriftPreset\n",
    "from evidently.test_suite import TestSuite\n",
    "from evidently.test_preset import DataDriftTestPreset, DataQualityTestPreset, DataStabilityTestPreset, NoTargetPerformanceTestPreset"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Prepare Datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "iris_data = datasets.load_iris(as_frame=True)\n",
    "iris = iris_data.frame\n",
    "\n",
    "iris_ref = iris.sample(n=75, replace=False)\n",
    "iris_cur = iris.sample(n=75, replace=False)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to change individual colors?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from evidently.options import ColorOptions\n",
    "\n",
    "color_scheme = ColorOptions(\n",
    "    primary_color = \"#5a86ad\",\n",
    "    fill_color = \"#fff4f2\",\n",
    "    zero_line_color = \"#016795\",\n",
    "    current_data_color = \"#c292a1\", \n",
    "    reference_data_color = \"#017b92\"\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to use existing color schemes?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from evidently.options import BERLIN_AUTUMN_COLOR_OPTIONS"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to customize color in Reports?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_drift_dataset_report = Report(metrics=[\n",
    "    DataDriftPreset()\n",
    "], options=[color_scheme]) \n",
    "\n",
    "data_drift_dataset_report.run(reference_data=iris_ref, current_data=iris_cur)\n",
    "data_drift_dataset_report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_drift_dataset_report = Report(metrics=[\n",
    "    DataDriftPreset()\n",
    "], options=[BERLIN_AUTUMN_COLOR_OPTIONS])\n",
    "\n",
    "data_drift_dataset_report.run(reference_data=iris_ref, current_data=iris_cur)\n",
    "data_drift_dataset_report"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to customize color in Test Suites?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from evidently.test_preset import DataDriftTestPreset\n",
    "\n",
    "data_drift_dataset_tests = TestSuite(tests=[\n",
    "    DataDriftTestPreset()\n",
    "], options=[color_scheme])\n",
    "\n",
    "data_drift_dataset_tests.run(reference_data=iris_ref, current_data=iris_cur)\n",
    "data_drift_dataset_tests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_drift_dataset_tests = TestSuite(tests=[\n",
    "    DataDriftTestPreset()\n",
    "], options=[BERLIN_AUTUMN_COLOR_OPTIONS])\n",
    "\n",
    "data_drift_dataset_tests.run(reference_data=iris_ref, current_data=iris_cur)\n",
    "data_drift_dataset_tests"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.17"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
